package org.eclipse.football;

import static org.junit.Assert.*;

import org.junit.Test;

public class DuplicatePlayers {

	@Test
	public void test() {
		// Instantiate a team
		Team team = new Team("team","user");
		
		// Instantiate two OffPlayers with identical names and teams
		OffPlayer off_player1 = new OffPlayer("off_player", "team");
		OffPlayer off_player2 = new OffPlayer("off_player", "team");
		
		// Get old number of offensive players on team
		int old_size = team.getOff_players().size();
		
		// Try to add both OffPlayers to team
		team.addOffPlayer(off_player1);
		team.addOffPlayer(off_player2);
		
		// Make sure both players were not added successfully
		if(team.getOff_players().size() == old_size + 2){
			// If they were then fail
			fail("Team allowed addition of duplicate offensive player");
		}
		
		// Instantiate two DefPlayers with identical names and team names
		DefPlayer def_player1 = new DefPlayer("def_player", "team");
		DefPlayer def_player2 = new DefPlayer("def_player", "team");
		
		// Get old number of defensive players on team
		old_size = team.getDef_players().size();
		
		// Try to add both DefPlayers to team
		team.addDefPlayer(def_player1);
		team.addDefPlayer(def_player2);
		
		// Make sure both players were not added successfully
		if(team.getDef_players().size() == old_size + 2){
			// If they were then fail
			fail("Team allowed addition of duplicate defensive player");
		}
		
		// Instantiate two kickers with identical name and identical team
		Kicker kicker1 = new Kicker("kicker", "team");
		Kicker kicker2 = new Kicker("kicker", "team");
		
		// Get old number of kickers on team
		old_size = team.getKickers().size();
		
		// Try to add both kickers to team
		team.addKicker(kicker1);
		team.addKicker(kicker2);
		
		// Make sure both kickers were not added successfully
		if(team.getKickers().size() == old_size + 2){
			// If they were fail
			fail("Team allowed addition of duplicate kicker");
		}
	}

}
